#include <stdio.h>
#include <stdlib.h>
void judge_if_exist(char *path1, char *path2, char *path3) {
	int choose;
	printf("judge it works\n");
	
	FILE *fp;

	if((fp = fopen(path1,"rb")) == NULL){
		printf("在目录下没有找到储存图书信息的book文件\n请选择  1--手动导入！  2--创建此文件\n");
		scanf("%d",&choose);
		switch(choose){
		case 2:if((fp = fopen(path1,"wb+")) != NULL)
				   printf("创建成功\n\n");
			break;
		case 1:printf("请把名为book的文件复制到目录下\n\n");
		}
		fclose(fp);
	}
	if((fp = fopen(path2,"rb")) == NULL){
		printf("在目录下没有找到储存借阅信息的borrow文件\n请选择  1--手动导入！  2--创建此文件\n");
		scanf("%d",&choose);
		switch(choose){
		case 2:if((fp=fopen("path2","wb+")) != NULL)
				   printf("创建成功\n\n");
			break;
		case 1:printf("请把名为borrow的文件复制到目录下\n\n");
		}
		fclose(fp);
	}
	if((fp = fopen(path3,"rb")) == NULL){
		printf("在目录下没有找到储存学生信息的student文件\n请选择  1--手动导入！  2--创建此文件\n");
		scanf("%d",&choose);
		switch(choose){
		case 2:if((fp = fopen("path3","wb+"))!=NULL)
				   printf("创建成功\n\n");
			break;
		case 1:printf("请把名为student的文件复制到目录下\n\n");
		}
		fclose(fp);
	}
}

int lines_of_file(char *filename) {
	int lines = 0;
	char ch;
	FILE *fp;
	if ((fp = fopen(filename, "rb")) == NULL) {
		printf("open file failed in function lines_of_file");
		exit(1);
	}

	rewind(fp);
	while ((ch = fgetc(fp)) != EOF) {
		if (ch == '\n') {
			lines++;
		}
	}
	fclose(fp);
	return lines;
}
